/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package miraligner;

import java.io.FileNotFoundException;
import java.io.IOException;

public class Main {


    public static void main(String[] args) throws FileNotFoundException, IOException {
        // TODO code application logic here
        String dir = "DB";
        
        //System.out.println(args[5]);
        //System.out.println(dir);
        //System.out.println(args.length);
        //map.readseq("test/test.fa","DB","hsa",1,3,3);
        //System.exit(0);
        if (args.length<6){
            System.out.println("\njava -jar miraligner mismatches trimming-nts addition-nts species read_seq_file miRBase_folder_files");
            System.out.println("\nexample:java -jar miraligner.jar 1 3 3 hsa test/test.fa DB");
            System.out.println("example: see output at miraligner/test/output.mirna.out & miraligner/test/output.mirna.opt");
            System.out.println("See more at: http://sourceforge.net/apps/mediawiki/adrec/index.php?title=Main_Page\n");
            System.out.println("\n");
            System.exit(1);
        }
        dir=args[5];
        //check input file
        boolean f=tools.checkinput(args[4]);
        boolean ftab=tools.checkinputtab(args[4]);
        //check directory
        
        //check species
        boolean sp=tools.checksp(dir,args[3]);
        if (Integer.parseInt(args[0])>1){
           System.out.println("Only allowed 0/1 mismatch");
           sp=false;
        }
        if (Integer.parseInt(args[1])>3){
           System.out.println("Only allowed 3 nucleotides as trimming");
           sp=false;
        }
        if (Integer.parseInt(args[2])>3){
           System.out.println("Only allowed 3 nucleotides as addition");
           sp=false;
        }
        if (sp  ){
            System.out.println("Go to mapping...");
            System.out.println("Mismatches: "+args[0]);
            System.out.println("Trimming: "+args[1]);
            System.out.println("Addition: "+args[2]);
            System.out.println("Species: "+args[3]);
            if (f){
                map.readseq(args[4],dir,args[3],Integer.parseInt(args[0]),Integer.parseInt(args[1]),Integer.parseInt(args[2]));
            }else if (ftab){
                map.readseqtab(args[4],dir,args[3],Integer.parseInt(args[0]),Integer.parseInt(args[1]),Integer.parseInt(args[2]));
            
            }else{
                System.out.println("no format file recognized (fasta or tabular)");
            }
       }
    }



}
